<?php
require_once('client'.EXT);
class Paramters extends Client{

	function __construct()
	{
		parent::__construct();
		$this->data['current']	=	'paramter';
	}
	
	function index()
	{
		$this->load->model('paramter_model');
		$paramter	=	$this->paramter_model->get_by('id',1);
		if($paramter){
			$this->data['paramter']	=	$paramter;
		}
		if($_SERVER['REQUEST_METHOD'] == 'POST')
		{
			$data	=	array(
				'inflation_rate'					=>	$this->input->post('textfield5'),
				'retirement_age'					=>	$this->input->post('textfield2'),
				'university_entry_age_for_male'		=>	$this->input->post('textfield11'),
				'university_entry_age_for_female'	=>	$this->input->post('textfield8'),
				'cost_of_university'				=>	$this->input->post('textfield9'),
				'education_inflation'				=>	$this->input->post('textfield10'),
				'date_update'						=>	date('Y-m-d H:i:s')
			);
			if($paramter){
				$this->paramter_model->update($paramter->id,$data);
			}
			else{
				$this->paramter_model->insert($data);
			}
			redirect(base_url().'paramters/');
		}
		$this->data['tpl_file']	=	'paramter/index';
		$this->load->view('layout/default',$this->data);
	}
}